#coding=utf-8
from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Message(models.Model):
    fromUser    = models.ForeignKey(User, verbose_name = '寄件人', related_name = 'from_user')
    toUser      = models.ForeignKey(User, verbose_name = '收件人', related_name = 'to_user')
    replyTo     = models.ForeignKey('self', verbose_name = '回复', null = True, blank = True)
    content     = models.CharField('内容', max_length = 1024)
    title       = models.CharField('标题', max_length = 64, blank = True)
    status      = models.CharField('状态', max_length = 32, default = 'NotRead')
    createDate  = models.DateTimeField('创建时间', auto_now_add = True)
    
    def __unicode__(self):
        return '%s' % (self.title)
        
    def get_absolute_url(self):
        return "/m/%s/" % str(self.id)
    
    class Meta:
	verbose_name_plural = '消息'